<template>
  <div id="app">
    <!-- <img alt="Vue logo" src="./assets/logo.png" /> -->
    <!-- <HelloWorld msg="Welcome to Your Vue.js App" /> -->
    <a href="#/home">首页</a>&nbsp;&nbsp;

    <a href="#/movie">电影</a>&nbsp;&nbsp;

    <a href="#/about">关于</a>

    <component :is="comName"></component>
  </div>
</template>

<script>
import MyHome from "./components/MyHome.vue";
import MyMovie from "./components/MyMovie.vue";
import MyAbout from "./components/MyAbout.vue";

export default {
  name: "App",
  components: {
    MyHome,
    MyMovie,
    MyAbout,
  },
  data() {
    return {
      comName: "MyHome",
    };
  },
  created() {
    window.onhashchange = () => {
      console.log(location.hash);
      let hash = location.hash;
      if (hash === "#/home") {
        this.comName = "MyHome";
      } else if (hash === "#/movie") {
        this.comName = "MyMovie";
      } else if (hash === "#/about") {
        this.comName = "MyAbout";
      } else {
        this.comName = "MyHome";
      }
    };
  },
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
